package com.itlong.cloud.enumerate;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <desc>
 *     多媒体资源发布状态枚举类
 * </desc>
 *
 * @createDate 2018/04/27
 */
public enum DeviceMediaInfoPublishStatusEnum {

    OUT_OF_DATE("已过期",0),
    PUBLISHED(" 已发布",1),
    UNPUBLISHED("未发布",2),
    UN_CHECKED("未审核", 3),
    UN_PASSES("未通过", 4);

    private String description;
    private Integer type;

    DeviceMediaInfoPublishStatusEnum(String value,Integer type) {
        this.type = type;
        this.description = value;
    }

    /**
     * {@link #description}的getter。
     */
    public String getDescription() {
        return description;
    }

    /**
     * {@link #type}的getter。
     */
    public Integer getType() {
        return type;
    }

    /**
     * <p>
     *     获取枚举的描述。
     * <p/>
     *
     * @param type  类型值。
     * @return {@link String}。
     */
    public static String getDescription(int type){
        DeviceMediaInfoPublishStatusEnum[] types = DeviceMediaInfoPublishStatusEnum.values();
        for(DeviceMediaInfoPublishStatusEnum limitCategory : types ){
            if(limitCategory.getType() == type){
                return limitCategory.getDescription();
            }
        }
        return null;
    }

    /**
     * <p>
     *     获取枚举的类型。
     * <p/>
     *
     * @param type  类型值。
     * @return {@link int}。
     */
    public static int getType(Integer type) {
        DeviceMediaInfoPublishStatusEnum[] types = DeviceMediaInfoPublishStatusEnum.values();
        for(DeviceMediaInfoPublishStatusEnum limitCategory : types ){
            if(limitCategory.getType() == type){
                return limitCategory.getType();
            }
        }
        return 0 ;
    }

    /**
     * <p>
     *     获取枚举的list。
     * <p/>
     *
     * @return {@link java.util.List}。
     */
    public static List<Map> toList() {
        List<Map> mapList = new ArrayList<Map>();
        DeviceMediaInfoPublishStatusEnum[] ds = DeviceMediaInfoPublishStatusEnum.values();
        for (DeviceMediaInfoPublishStatusEnum one : ds) {
            Map<String,Object> term= new HashMap<String,Object>();
            term.put("type",one.getType());
            term.put("description",one.getDescription());
            mapList.add(term);
        }
        return mapList;
    }


}
